import { observable, configure, makeObservable, action } from 'mobx';

configure({
  enforceActions: 'always',
});

// const store = observable(
//   {
//     tabbarShow: true,
//     cityList: [],
//     city: { name: '北京', id: 110100 },
//     changeTabbarShow() {
//       console.log('changeTabbarShow');
//       this.tabbarShow = true;
//     },
//     changeTabbarHide() {
//       console.log('changeTabbarHide');
//       this.tabbarShow = false;
//     },
//   },
//   {
//     changeTabbarShow: action, // 标记是action
//     changeTabbarHide: action,
//   }
// );

class Store {
  @observable tabbarShow = true;
  @observable cityList = [];
  @observable city = { name: '北京', id: 110100 };

  constructor() {
    makeObservable(this);
  }

  @action changeCity(city) {
    console.log('changeCity');
    this.city = city;
  }

  @action changeCityList(cityList) {
    console.log('changeCityList');
    this.cityList = cityList;
  }

  @action changeTabbarShow() {
    console.log('changeTabbarShow');
    this.tabbarShow = true;
  }

  @action changeTabbarHide() {
    console.log('changeTabbarHide');
    this.tabbarShow = false;
  }
}

const store = new Store();

export default store;
